<?php
 //  Просмотр вопросов ______________________________________________________________

 
    $connection = connect($config);
 
 if(isset($_GET['page']) && $_GET['jurist'] == 'question_answer'){

    $articlres = getAllPosts($connection, "SELECT * FROM question WHERE `Apruft` = 1");         
    $allcount = count($articlres);
 
    $limit1 = 0;
    $limit2 = 10; 
 
         if ($allcount > 10)
        {
            $pagestr = $allcount / 10;
            $pagestr = ceil($pagestr);
   
            for ($i = 1;$i <= $pagestr;$i++)
            {
            echo "<a href='/jurist/question_answer&page=".$i."'> $i </a>";
            }
        }
 
    $getstr = $_GET['page'];
 
    for ($g = 1; $g < $getstr; $g++)
    {
        $limit1 = $limit1 + 10;
        $limit2 = $limit2 + 10;
    }
 
    $articlres = getAllPosts($connection, "SELECT * FROM question WHERE `Apruft` = 1
                ORDER BY QuestionDate DESC LIMIT $limit1,$limit2");
 
 
    $countart = count($articlres);
 
 
    for ($i = 0;$i < $countart; $i++)
    {
    
        $s1 = substr($articlres[$i][Answer],0,350);
        
        $s2 =  strlen($articlres[$i][Answer]);
        
        echo "<h1><a href='/jurist/question_answer&question=".$articlres[$i][QuestionID]."'>".$articlres[$i][Question]."</a></h1>";
    
        echo "<p>".$s1;
        if($s2 > 350) echo ".....";
        echo "</p>";
        
        if($s2 > 350) echo "<a href='/jurist/question_answer&question=".$articlres[$i][QuestionID]."'>Читать дальше ></a>";

    
    }
} 
 
// Просмотр самого вопроса __________________________________________

if(isset($_GET['question']))
{
   
    $getID = array('id' => $_GET['question']);
    
    $articlres = query("SELECT * FROM question WHERE `QuestionID` = :id", $getID, $connection);
   
   
    echo "<h1>".$articlres[0][Question]."</h1>";
    echo "<p><span>".$articlres[0][QuestionDate]."</span></p>";
    echo "<p><span>".$articlres[0][Answer]."</span></p>";   
    
}



 
	  
?>